#pragma once

extern "C"
{
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libswscale/swscale.h"
#include "libavdevice/avdevice.h"
#include <libavutil/imgutils.h>
};
#include <string>
using namespace std;
#include <stdint.h>

class video
{
public:
	video();
	~video();

	bool open(const string& filename);
	int getTotalTime();
	int getBitRate();
	bool locate(int second);
	void close();

//private:
	int decodeOnFrame();

private:
	AVFormatContext*	pFormatCtx;
	AVCodecContext*		pCodecCtx;
	AVPacket            packet;
	AVFrame*			frame;
	int					width;
	int					height;
	AVPixelFormat		pix_fmt;
	int					videoindex;
	uint8_t*            video_dst_data[4];
	int                 video_dst_linesize[4];
	int					video_dst_bufsize;
};
